package wox.lonice.enums.leguan;

/**
 * 平台
 */
public enum PlatformEnum {
    wechat(0, "微信"),
    headline(1, "今日头条"),
    information(2, "一点资讯"),
    lingcod(3, "大鱼号"),
    baidu(4, "百家号"),
    sohu(5, "搜狐号"),
    netease(6, "网易号"),
    ;

    private final int value;

    private final String name;

    PlatformEnum(int value, String name) {
        this.value = value;
        this.name = name;
    }

    /**
     * Return the integer value of this status code.
     */
    public Integer value() {
        return this.value;
    }

    /**
     * Return the name of this status code.
     */
    public String getName() {
        return this.name;
    }

    /**
     * Return a string representation of this status code.
     */
    @Override
    public String toString() {
        return Integer.toString(this.value);
    }

    /**
     *
     * @param name
     * @return
     */
    public static PlatformEnum nameOf(String name) {
        for (PlatformEnum item : values()) {
            if (item.name.equals(name)) {
                return item;
            }
        }
        throw new IllegalArgumentException("No matching constant for [" + name + "]");
    }

    /**
     *
     * @param code
     * @return
     */
    public static PlatformEnum valueOf(int code) {
        for (PlatformEnum item : values()) {
            if (item.value == code) {
                return item;
            }
        }
        throw new IllegalArgumentException("No matching constant for [" + code + "]");
    }
}
